itemNetworkIDprofile = getStatus("itemNetworkID").replace("\r", "").split("\n")
if "获取失败" in itemNetworkIDprofile:
    raise Exception("§4无法读取物品ID表, 文件位置: status\\itemNetworkID.txt")
color("§e不要修改/删除 status\\itemNetworkID.txt, 否则会出问题")
itemNetworkID2NameDict = {}
itemNetworkID2NameEngDict = {}
for i in itemNetworkIDprofile:
    itemNetworkID2NameDict[i.split(" ")[0]] = i.split(" ")[2]
    itemNetworkID2NameEngDict[i.split(" ")[0]] = i.split(" ")[1]

# 获取玩家手持物品名称并返回.
def getMainhandItem(targetName):
    global needToGetMainhandItem, itemMainhand, targetMainhand
    if targetName not in allplayers:
        raise Exception("player not found")
    timeStartGetMainhandItem = time.time()
    itemMainhand = {}
    targetMainhand = targetName
    needToGetMainhandItem = True
    sendcmd("/gamemode c")
    sendcmd("/effect @s invisibility 5 0 true")
    sendcmd("/tp @s @a[name=%s]" % targetName)
    time.sleep(0.1)
    sendcmd("/tp 10000 10000 10000")
    time.sleep(0.1)
    while True:
        if int(time.time() - timeStartGetMainhandItem) > 1:
            targetMainhand = ""
            needToGetMainhandItem = False
            raise Exception("timed out")
        if not(needToGetMainhandItem):
            targetMainhand = ""
            return itemMainhand
        time.sleep(0.05)

# 获取玩家装备名称并返回.
def getArmorItem(targetName):
    global needToGetArmorItem, itemArmor, targetArmor
    if targetName not in allplayers:
        raise Exception("player not found")
    timeStartGetArmorItem = time.time()
    itemArmor = {}
    targetArmor = targetName
    needToGetArmorItem = True
    sendcmd("/gamemode c")
    sendcmd("/effect @s invisibility 5 0 true")
    sendcmd("/tp @s @a[name=%s]" % targetName)
    time.sleep(0.1)
    sendcmd("/tp 10000 10000 10000")
    time.sleep(0.1)
    while True:
        if int(time.time() - timeStartGetArmorItem) > 1:
            targetArmor = ""
            needToGetArmorItem = False
            raise Exception("timed out")
        if not(needToGetArmorItem):
            targetArmor = ""
            return itemArmor
        time.sleep(0.05)
